/*
 * @Author: long
 * @Date: 2021-09-13 11:29:52
 * @LastEditTime: 2021-10-27 09:51:55
 * @LastEditors: Please set LastEditors
 * @Description: 页面固态 + 动态路由；
 * 
 *                元信息中的roles解释（roles:'root, iam, 2'）：
 *                'root'（根账户，具有所有权），'iam'(子用户，具有部分权限, 具体权限表请查原型中所示)，
 *                字符串数字（菜单id）
 * 
 *                动态可配置的菜单id和操作id所对应的名称如下：
 *                ~菜单id：1-总览、2-总览工作台、
 *                        16-服务管理、17-服务概览、18-资源管理、19-服务报表、20-服务关联数据库、21-sass服务
 * 
 *                ~操作id：1-查看工作台、2-修改视图、3-自定义快速访问
 *                        36-查看服务概览、37-查看资源列表、39-查看服务报表、40-导出服务报表、41-查看数据库、42-修改数据库、43-登录
 * 
 * @FilePath: \ant-design-vue-jeecge:\hjimi\人脸辨识云\html\gitlab\pc\faceCloudWebsite\src\router\index.js
 */
import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

import Layout from '@/layout'
export const constantRoutes = [
  {
    path: '/redirect',
    component: Layout,
    hidden: true,
    children: [
      {
        path: '/redirect/:path(.*)',
        component: () => import('@/views/redirect/index')
      }
    ]
  },
  {
    path: '/login',
    component: () => import('@/views/login/index'),
    hidden: true
  },
  {
    path: '/auth-redirect',
    component: () => import('@/views/login/auth-redirect'),
    hidden: true
  },
  {
    path: '/explain',
    component: () => import('@/views/explain/index'),
    hidden: true
  },
  {
    path: '/reg',
    component: () => import('@/views/login/reg'),
    hidden: true
  },
  {
    path: '/regSuccess',
    component: () => import('@/views/login/regSuccess'),
    hidden: true
  },
  {
    path: '/404',
    component: () => import('@/views/error-page/404'),
    hidden: true
  }, 
  {
    path: '/401',
    component: () => import('@/views/error-page/401'),
    hidden: true
  },
  {
    path: '/',
    component: Layout,
    redirect: '/dashboard',
    children: [
      {
        path: 'dashboard',
        component: () => import('@/views/dashboard/index'),
        name: 'dashboard',
        meta: { title: '总览', icon: 'home', affix: true},
        hidden: true
      }
    ]
  },
]

/**
 * @description: 动态路由切换表
 */
export var asyncRoutes = [

// 2D人脸识别
  {
    path: '/all-services',
    component: Layout,
    meta: { mark: '2DFACE', roles:['17'] },
    children: [
      {
        path: '',
        name: 'allSevices',
        component: () => import('@/views/face-recognition/all-services'),
        meta: { title: '服务概览', icon: 'el-icon-tickets', mark: '2DFACE' },
      },
    ],
  },
  {
    path: '/resource-manage',
    component: Layout,
    redirect: '/resource-manage/resourceList',
    meta: { roles: ['18'], mark: '2DFACE' },
    children: [
      {
        path: 'resourceList',
        name: 'resourceList',
        component: () => import('@/views/face-recognition/resource-manage/resource-list/resourceList'),
        meta: { title: '资源管理', icon: 'sdk', mark: '2DFACE'},
      },
      {
        path: 'usageDetails',
        name: 'usageDetails',
        component: () => import('@/views/face-recognition/resource-manage/usage-details/usageDetails'),
        meta: { title: '使用详情', mark: '2DFACE' },
        hidden: true
      },
      {
        path: 'resourcePay',
        name: 'resourcePay',
        component: () => import('@/views/face-recognition/resource-manage/resource-pay/resourcePay'),
        meta: { title: '资源购买', mark: '2DFACE' },
        hidden: true
      },
    ]
  },
  {
    path: '/faceLibrary-manage',
    component: Layout,
    redirect: '/faceLibrary-manage/faceLibraryList',
    meta: { mark: '2DFACE', roles: ['20'] },
    children: [
      {
        path: 'faceLibraryList',
        name: 'faceLibraryList',
        component: () => import('@/views/face-recognition/faceLibrary-manage/faceLibraryList'),
        meta: { title: '脸库管理', icon: 'people', mark: '2DFACE' },
      },
      {
        path: 'faceLibraryDetails',
        name: 'faceLibraryDetails',
        component: () => import('@/views/face-recognition/faceLibrary-manage/faceLibraryDetails'),
        meta: { title: '脸库详情', icon: 'people', mark: '2DFACE' },
        hidden: true
      }
    ]
  },
  {
    path: '/service-log',
    component: Layout,
    meta: { mark: '2DFACE', roles: ['19']},
    children: [
      {
        path: '',
        name: 'serviceLog',
        component: () => import('@/views/face-recognition/service-log'),
        meta: { title: '服务报表', icon: 'log', mark: '2DFACE' },
      },
    ]
  },

// 3D人体建模
  {
    path: '/modeling-allServices',
    component: Layout,
    meta: { mark: '3DMODELING' },
    children: [
      {
        path: '',
        name: 'modelingAllServices',
        component: () => import('@/views/modeling/modeling-allServices'),
        meta: { title: '服务概览', icon: 'el-icon-tickets', mark: '3DMODELING' },
      },
    ],
  },
  {
    path: '/modeling-resourceManage',
    component: Layout,
    redirect: '/resource-manage/resourceList',
    meta: { mark: '3DMODELING' },
    children: [
      {
        path: 'resourceList',
        name: 'resourceList',
        component: () => import('@/views/modeling/modeling-resourceManage/resource-list/resourceList'),
        meta: { title: '资源管理', icon: 'sdk', mark: '3DMODELING'},
      }
    ]
  },
  {
    path: '/model-manage',
    component: Layout,
    redirect: '/model-manage/modelList',
    meta: { mark: '3DMODELING', roles: ['20'] },
    children: [
      {
        path: 'faceLibraryList',
        name: 'faceLibraryList',
        component: () => import('@/views/modeling/model-manage/modelList'),
        meta: { title: '模型库管理', icon: 'people', mark: '3DMODELING' },
      },
      {
        path: 'modelDetsils',
        name: 'modelDetsils',
        component: () => import('@/views/modeling/model-manage/modelDetails'),
        meta: { title: '模型库详情', icon: 'people', mark: '3DMODELING' },
        hidden: true
      },
    ]
  },
  {
    path: '/model-serviceLog',
    component: Layout,
    meta: { mark: '3DMODELING'},
    children: [
      {
        path: '',
        name: 'modelServiceLog',
        component: () => import('@/views/modeling/model-serviceLog'),
        meta: { title: '服务报表', icon: 'log', mark: '3DMODELING' },
      },
    ]
  },

// 财务中心
  {
    path: '/financial-view',
    component: Layout,
    meta: { mark: 'CWZX' },
    children: [
      {
        path: 'financialView',
        name: 'financialView',
        component: () => import('@/views/finance-center/financial-view/financialView'),
        meta: { title: '财务概览', icon: 'el-icon-document', mark: 'CWZX' },
      },
      
    ]
  },
  {
    path: '/order-manage',
    component: Layout,
    meta: { mark: 'CWZX' },
    children: [
      {
        path: 'orderManage',
        name: 'orderManage',
        component: () => import('@/views/finance-center/order-manage/orderManage'), 
        meta: { title: '订单管理', icon: 'el-icon-notebook-2', mark: 'CWZX' },
      },
    ]
  },
  {
    path: '/invoice-manage',
    component: Layout,
    meta: { mark: 'CWZX' },
    children: [
      {
        path: 'invoiceManage',
        name: 'invoiceManage',
        component: () => import('@/views/finance-center/invoice-manage/invoiceManage'),
        meta: { title: '发票管理', icon: 'invoiceManage', mark: 'CWZX' },
      }
    ]
  },

// 多用户管理
  {
    path: '/iam-manage',
    component: Layout,
    meta: { mark: 'DYHGL', roles: 'root' },
    redirect: '/iam-manage/iamList',
    children: [
      {
        path: 'iamList',
        name: 'iamList',
        component: () => import('@/views/iam-manage/iam-list/iamList'),
        meta: { title: 'IAM用户管理', icon: 'peoples', roles:'root', mark: 'DYHGL' },
      },
      {
        path: 'iamDetails',
        name: 'iamDetails',
        component: () => import('@/views/iam-manage/iam-details/iamDetails'),
        meta: { title: 'IAM用户详情', icon: 'el-icon-user', roles:'root', mark: 'DYHGL' },
        hidden: true
      }
    ]
  },
  {
    path: '/iam-log',
    component: Layout,
    redirect: 'iamLog',
    meta: { mark: 'DYHGL' },
    children: [
      {
        path: 'iamLog',
        name: 'iamLog',
        component: () => import('@/views/iam-manage/iam-log/iamLog'),
        meta: { title: '操作日志', icon: 'log', roles:'root, iam', mark: 'DYHGL' },
      },
    ]
  },
  {
    path: '/iam-role',
    component: Layout,
    redirect: 'roleList',
    meta: { title: '角色管理', icon: 'role', roles:'root, iam', mark: 'DYHGL' },
    children: [
      {
        path: 'roleList',
        name: 'roleList',
        component: () => import('@/views/iam-manage/iam-role/roleList'),
        meta: { title: '角色列表', icon: 'list', roles:'root, iam', mark: 'DYHGL' },
      },
      {
        path: 'addRole',
        name: 'addRole',
        component: () => import('@/views/iam-manage/iam-role/addRole'),
        meta: { title: '新增角色', icon: 'add', roles:'root', mark: 'DYHGL' },
      },
      {
        path: 'roleDetails',
        name: 'roleDetails',
        component: () => import('@/views/iam-manage/iam-role/roleDetails'),
        meta: { title: '角色详情', roles:'root, iam', mark: 'DYHGL' },
        hidden: true
      },
      {
        path: 'editRole',
        name: 'editRole',
        component: () => import('@/views/iam-manage/iam-role/editRole'),
        meta: { title: '编辑角色', roles:'root', mark: 'DYHGL' },
        hidden: true
      }
    ]
  },

// 账号中心
  {
    path: '/personal-data',
    component: Layout,
    meta: { mark: 'ZHZX'},
    children: [
      {
       path: 'personalData',
       name: 'personalData',
       component: () => import('@/views/personal-center/personal-data/personalData'),
       meta: { title: '个人资料', icon: 'personalMsg', roles:'root, iam', mark: 'ZHZX' },
     }
    ],
  },
  {
    path: '/enterprise-data',
    component: Layout,
    meta: { mark: 'ZHZX'},
    children: [
      {
       path: 'enterpriseData',
       name: 'enterpriseData',
       component: () => import('@/views/personal-center/enterprise-data/enterpriseData'),
       meta: { title: '企业资料', icon: 'enterpriseMsg', roles:'root, iam', mark: 'ZHZX' },
     }
    ]
  },

  // 应用中心
  {
    path: '/application-manage', 
    component: Layout,
    redirect: 'applicationList',
    meta: { roles: ['iam'], mark: 'YYZX' },
    children: [
      {
        path: 'applicationList',
        name: 'applicationList',
        component: () => import('@/views/application-manage/applicationList'),
        meta: { title: '应用列表', icon: 'list', mark: 'YYZX' },
      },
      {
        path: 'editApplication',
        name: 'editApplication',
        component: () => import('@/views/application-manage/editApplication'),
        meta: { title: '应用设置', icon: 'el-icon-user', mark: 'YYZX' },
        hidden: true
      }
    ]
  },
  {
    path: '/application-manage/addApplication', 
    component: Layout,
    meta: { roles: ['iam'], mark: 'YYZX' },
    children: [
      {
        path: '',
        name: 'addApplication',
        component: () => import('@/views/application-manage/addApplication'),
        meta: { title: '新增应用', icon: 'add', mark: 'YYZX' }
      },
    ]
  },
  {
    path: '/application-log',
    component: Layout,
    redirect: '/application-manage/applicationList',
    meta: { mark: 'YYZX', roles: ['root','iam'] },
    children: [
      {
        path: 'applicationLog',
        name: 'applicationLog',
        component: () => import('@/views/application-manage/application-log/applicationLog'),
        meta: { title: '报表日志', icon: 'log', mark: 'YYZX' },
      }
    ]
  },

  
  // {
  //   path: '/sass-manage',
  //   component: Layout,
  //   children: [
  //     {
  //       path: 'sassList',
  //       name: 'sassList',
  //       component: () => import('@/views/sass-manage/sassList/sassList'),
  //       meta: { title: 'SasS服务', icon: 'sass' },
  //     },
  //     {
  //       path: 'sassDes',
  //       name: 'sassDes',
  //       component: () => import('@/views/sass-manage/sassList/sassDes'),
  //       meta: { title: 'SasS服务详情', icon: 'sass'},
  //       hidden: true 
  //     },
  //   ]
  // },
  // {
  //   path: '/pass-manage',
  //   component: Layout,
  //   children: [
  //     {
  //       path: 'passList',
  //       name: 'passList',
  //       component: () => import('@/views/pass-manage/passList/passList'),
  //       meta: { title: 'PasS服务', icon: 'sdk' },
  //     },
  //   ]
  // },
  // {
  //   path: '/documents',
  //   component: Layout,
  //   children: [
  //     {
  //       path: 'docList',
  //       name: 'docList',
  //       component: () => import('@/views/documents/docs/docList'),
  //       meta: { title: '文档中心', icon: 'docs' },
  //     },
  //   ]
  // },
  // {
  //   path: '/about',
  //   component: Layout,
  //   children: [
  //     {
  //       path: 'index',
  //       name: 'about',
  //       component: () => import('@/views/about/index'),
  //       meta: { title: '关于', icon: 'about' }
  //     }
  //   ]
  // },
  { path: '*', redirect: '/404', hidden: true }
]


const createRouter = () => new Router({
  // mode: 'history', // require service support
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRoutes
})

const router = createRouter()

// 路由重置
export function resetRouter() {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher
}


// 全局配置TDK
const HEAD = document.getElementsByTagName('head')[0]
let meta_keywords = document.createElement('meta')
    meta_keywords.name = 'description'
    meta_keywords.content = '人工智能AI,智能云服务平台,华捷艾米'
    HEAD.appendChild(meta_keywords)

export default router